static factory method meaning in English
静态工厂方法
Examples
- To obtain the player instance , you must call a static factory method of the
要获得播放器实例,则必须在 - One advantage of static factory methods is that , unlike constructors , they have names
静态工厂方法的一个好处是,与构造函数不同,静态工厂方法具有名字。 - A third advantage of static factory methods is that , unlike constructors , they can return an object of any subtype of their return type
第三个好处是,与构造函数不同,它们可以返回一个原返回类型的子类型的对象。 - In summary , static factory methods and public constructors both have their uses , and it pays to understand their relative merits
总而言之,静态工厂方法和构造函数均有各自的适用性,掌握他们不同的适用场所是很有用的。 - For example , the static factory method boolean . valueof ( string ) is almost always preferable to the constructor boolean ( string )
为了避免造成重复创建对象,如果一个类提供了静态的方法来创建对象,最好是优先使用静态方法。